<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var hammingWeight = function(n) {
    var count = 0
    n = n.toString(2)
    for( var i = 0 ; i<n.length ; i++ ){
        if( n[i] === '1' ){
            count++
        }
    }
    return count
};

var n = 00000000000000000000000000001011
console.log(hammingWeight(n))
    </script>
</body>
</html>